(function() {
	
this.pasta = this.pasta || {};
this.pasta.webgui = this.pasta.webgui || {};

this.pasta.webgui.ContainerControl = pasta.webgui.Control.extend(
{
	init : function() 
	{
		this._super();
		
		this.controls = new pasta.util.ArrayList();
		
		this.clientCanvas = document.createElement("div");
		this.clientCanvas.id = this.cid + "_client";
		this.clientCanvas.style.position = "absolute";
		this.clientCanvas.style.left = "0px";
		this.clientCanvas.style.top = "0px";
		this.clientCanvas.style.width = "100%";
		this.clientCanvas.style.height = "100%";
		
		this.canvas.appendChild(this.clientCanvas);
		this.highestZIndex = 1;
		this.lowestZIndex = -1;
	},

	bringChildToFront : function(child)
	{
		child.getCanvas().style.zIndex = this.highestZIndex;
		this.highestZIndex++;
	},
	
	sendChildToBack : function(child)
	{
		child.getCanvas().style.zIndex = this.lowestZIndex;
		this.lowestZIndex--;
	},
	
	addControl : function(control) 
	{	
		if (control instanceof pasta.webgui.Control)
		{
			control.parentId = this.cid;
			this.controls.add(control);
			this.clientCanvas.appendChild(control.canvas);
			
			control.doAddedToStage();
		}
	},
	
	delControl : function(control)
	{
		if (this.controls.indexOf(control) >= 0)
		{
			this.controls.delByObject(control);
			this.clientCanvas.removeChild(control.canvas);
		}
	},
	
	clear : function()
	{
		for (var i = 0; i < this.controls.getLength(); i++)
		{
			var control = this.controls.get(i);
			
			this.clientCanvas.removeChild(control.canvas);
		}
		
		this.controls.clear();
	},
	
	//------------------- setter & getter ---------------------
	
	getClipMode : function()
	{
		return this.clientCanvas.style.overflow;
	},
	
	setClipMode : function(mode)
	{
		this.clientCanvas.style.overflow = mode;
	}
});

})();